# coding: utf-8
from sqlalchemy import CHAR, Column, JSON, String, TIMESTAMP, Table, Text, text, MetaData
from sqlalchemy.dialects.mysql import ENUM, INTEGER, LONGTEXT, MEDIUMINT, MEDIUMTEXT, TEXT, TINYINT, VARCHAR
from ..database import db,serialize


class Article(db.Model):
    __tablename__ = 'articles'

    id = Column(INTEGER(11), primary_key=True)
    cate_id = Column(INTEGER(11), nullable=False, index=True)
    title = Column(String(255, 'utf8mb4_unicode_ci'), nullable=False)
    keywords = Column(String(255, 'utf8mb4_unicode_ci'), server_default=text("''"), comment='关键字')
    thumb = Column(String(200, 'utf8mb4_unicode_ci'))
    describe = Column(String(500, 'utf8mb4_unicode_ci'))
    content = Column(LONGTEXT, nullable=False)
    source = Column(String(50, 'utf8mb4_unicode_ci'))
    sort = Column(MEDIUMINT(8), nullable=False, server_default=text("'0'"))
    hits = Column(INTEGER(11), nullable=False, server_default=text("'99'"), comment='点击量')
    publish_at = Column(TIMESTAMP)
    push_flag = Column(TINYINT(4), nullable=False, server_default=text("'0'"), comment='1推荐，0不推荐')
    url = Column(CHAR(50, 'utf8mb4_unicode_ci'), nullable=False, index=True)
    tpl = Column(String(50, 'utf8mb4_unicode_ci'), nullable=False, server_default=text("'show'"))
    del_flag = Column(TINYINT(4), nullable=False, server_default=text("'0'"), comment='1删除，0正常')
    created_at = Column(TIMESTAMP)
    updated_at = Column(TIMESTAMP)

